import {CHANGE_LOGIN_STATUS} from "./const";
import {setAuthority} from "../../utils/authority";

const initState = {
  status: undefined,
  type: undefined,
};

const reducer = (state = initState, {type, payload}) => {
  switch (type) {
    case CHANGE_LOGIN_STATUS:
      setAuthority(payload.currentAuthority);
      return {
        ...state,
        status: payload.status,
        type: payload.type || 'account',
      };
    default:
      return state;
  }
};

export default reducer;
